home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / UCRASM25.ARJ / STRCPY.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  1KB  |  62 lines

  1. StdGrp        group    stdlib,stddata
  2. stddata        segment    para public 'sldata'
  3. stddata        ends
  4. ;
  5. stdlib        segment    para public 'slcode'
  6.         assume    cs:stdgrp
  7. ;
  8. ;
  9. ; strcpy- Copies string pointed at by es:di to string pointed at by dx:si.
  10. ;      (Sorry for the ackward use of registers, this matches the rest
  11. ;       of the standard library though).
  12. ;
  13. ; inputs:
  14. ;        es:di-    Zero-terminated source string.
  15. ;        dx:si-  Buffer for destination string.
  16. ;
  17. ; outputs:    es:di-    Points at destination string.
  18. ;
  19. ; Note: The destination buffer must be large enough to hold the string and
  20. ;    zero terminating byte.
  21. ;
  22.         public    sl_strcpy
  23. ;
  24. sl_strcpy    proc    far
  25.         push    ds
  26.         push    cx
  27.         push    ax
  28.         pushf
  29.         push    si
  30. ;
  31.         cld
  32.         mov    al, 0
  33.         mov    cx, 0ffffh
  34.         push    di
  35.     repne    scasb
  36.         pop    di
  37.         neg    cx
  38.         mov    ax, es
  39.         mov    ds, ax
  40.         mov    es, dx
  41.         xchg    si, di
  42.         dec    cx
  43.         shr    cx, 1
  44.         jnc    CpyWrd
  45.         lodsb
  46.         stosb
  47. CpyWrd:    rep    movsw
  48. ;
  49. DidByte:    pop    si
  50.         popf
  51.         pop    ax
  52.         pop    cx
  53.         pop    ds
  54.         mov    es, dx
  55.         mov    di, si
  56.         ret
  57. sl_strcpy        endp
  58. ;
  59. ;
  60. stdlib        ends
  61.         end
  62.